object Practise1 {
  def averageLessThanN(numbers: List[Int], n: Int): Option[Double] = {
    val filter_n = numbers.filter(_ < n)

    if (filter_n.nonEmpty) {
      Some(filter_n.sum.toDouble / filter_n.size)
    } else {
      None 
    }
  }

  def main(args: Array[String]): Unit = {
    val numbers = List(1,2,3,4,5) 
    val n = 4
    val average = averageLessThanN(numbers, n)
    println(average)

    average match {
      case Some(avg) => println(s"小于 $n 的数的平均值是: $avg")
      case None => println(s"没有小于 $n 的数")
    }
  }
}